home *** CD-ROM | disk | FTP | other *** search
- <xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:vendor="http://xml.apache.org/xalan"
- xmlns:myDistribution="f:myDistribution"
- exclude-result-prefixes="xsl vendor myDistribution"
- >
-
- <xsl:import href="random.xsl"/>
-
- <myDistribution:myDistribution>
- <o>1</o><p>0.2</p>
- <o>2</o><p>0.25</p>
- <o>3</o><p>0.25</p>
- <o>4</o><p>0.15</p>
- <o>5</o><p>0.1</p>
- <o>6</o><p>0.05</p>
- </myDistribution:myDistribution>
-
- <xsl:output indent="yes" omit-xml-declaration="yes"/>
-
- <xsl:variable name="NL" select="'
'"/>
-
- <xsl:template match="/">
-
- <xsl:variable name="vrtfUnscaledRandoms">
- <xsl:call-template name="randomSequence">
- <xsl:with-param name="pLength" select="100"/>
- </xsl:call-template>
- </xsl:variable>
-
- <xsl:variable name="vUnscaledRandoms"
- select="vendor:node-set($vrtfUnscaledRandoms)/*"/>
-
- 100 Randoms in (0,<xsl:value-of select="$modulus - 1"/>):
- <xsl:for-each select="$vUnscaledRandoms
- [position() mod 8 = 1]">
- <xsl:value-of select="$NL"/>
- <xsl:for-each
- select=". | following::*[position() < 8]">
- <xsl:value-of select="concat(., ', ')"/>
- </xsl:for-each>
- </xsl:for-each>
-
- <xsl:variable name="vStart" select="1"/>
- <xsl:variable name="vEnd" select="10"/>
-
- <xsl:value-of select="concat($NL,$NL,
- '100 Randoms in (',
- $vStart, ', ',
- $vEnd, '):',
- $NL
- )"/>
- <xsl:variable name="vrtfScaledRandoms">
- <xsl:call-template name="randomSequence">
- <xsl:with-param name="pLength" select="100"/>
- <xsl:with-param name="pStart" select="$vStart"/>
- <xsl:with-param name="pEnd" select="$vEnd"/>
- </xsl:call-template>
- </xsl:variable>
-
- <xsl:variable name="vScaledRandoms"
- select="vendor:node-set($vrtfScaledRandoms)/*"/>
-
- <xsl:for-each select="$vScaledRandoms
- [position() mod 10 = 1]">
- <xsl:value-of select="$NL"/>
- <xsl:for-each
- select=". | following::*[position() < 10]">
- <xsl:value-of select="concat(., ', ')"/>
- </xsl:for-each>
- </xsl:for-each>
-
- <xsl:value-of select="concat($NL,$NL,
- 'Randoms 11-20 in (',
- $vStart, ', ',
- $vEnd, '):',
- $NL
- )"/>
- <xsl:variable name="vrtfRandSubsequence">
- <xsl:call-template name="randomSubSequence">
- <xsl:with-param name="pLength" select="10"/>
- <xsl:with-param name="pSubStart" select="11"/>
- <xsl:with-param name="pStart" select="$vStart"/>
- <xsl:with-param name="pEnd" select="$vEnd"/>
- </xsl:call-template>
- </xsl:variable>
-
- <xsl:copy-of
- select="vendor:node-set($vrtfRandSubsequence)/*"/>
-
- <xsl:variable name="vrtfDistRandSeq">
- <xsl:call-template name="dist-randomSequence">
- <xsl:with-param name="pLength" select="100"/>
- <xsl:with-param name="pDist"
- select="document('')/*/myDistribution:*[1]/*"/>
-
- </xsl:call-template>
- </xsl:variable>
-
- <xsl:value-of select="concat($NL,$NL,
- '100 Random outcomes 1-6 with distribution:
'
- )"/>
- <xsl:copy-of
- select="document('')/*/myDistribution:*[1]"/>
- <xsl:value-of
- select="concat($NL, $NL, 'Results:', $NL)"/>
-
- <xsl:variable name="vDistRandSeq"
- select="vendor:node-set($vrtfDistRandSeq)/*"/>
-
- <xsl:for-each select="$vDistRandSeq
- [position() mod 10 = 1]">
- <xsl:value-of select="$NL"/>
- <xsl:for-each
- select=". | following::*[position() < 10]">
- <xsl:value-of select="concat(., ', ')"/>
- </xsl:for-each>
- </xsl:for-each>
-
- <xsl:value-of select="concat($NL,$NL,
- 'Randoms 11-20 with the same distribution:',
- $NL
- )"/>
- <xsl:variable name="vrtfDistRandSubsequence">
- <xsl:call-template name="dist-randomSubSequence">
- <xsl:with-param name="pLength" select="10"/>
- <xsl:with-param name="pSubStart" select="11"/>
- <xsl:with-param name="pDist"
- select="document('')/*/myDistribution:*[1]/*"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:copy-of
- select="vendor:node-set($vrtfDistRandSubsequence)/*"/>
- </xsl:template>
- </xsl:stylesheet>